| 1 | import { NextResponse, type NextRequest } from "next/server"; |
| 2 | import { getMemberVotesForYear } from "@/lib/feed"; |
| 3 | |
| 4 | export const dynamic = "force-dynamic"; |
| 5 | |
| 6 | |
| 7 | export async function GET( |
| 8 | req: NextRequest, |
| 9 | { params }: { params: { id: string } } |
| 10 | ) { |
| 11 | const bioguide = params.id.toUpperCase(); |
| 12 | const yearStr = req.nextUrl.searchParams.get("year"); |
| 13 | const year: number | null = |
| 14 | yearStr && yearStr !== "null" ? parseInt(yearStr, 10) : null; |
| 15 | |
| 16 | const votes = getMemberVotesForYear(bioguide, year); |
| 17 | return NextResponse.json({ votes, year }, { |
| 18 | headers: { "Cache-Control": "public, s-maxage=300, stale-while-revalidate=600" }, |
| 19 | }); |
| 20 | } |